<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kartik\file\FileInput;
use kartik\select2\Select2;
use yii\web\JsExpression;
use app\common\Functions;

/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\BizRuleModel */
/* @var $form ActiveForm */
?>

<?php

$fieldOptions  = [];
$labelOptions  = [];
$fieldOptions['class']  = 'col-md-6';
$options['options']=$fieldOptions;
$selectOptions = [];
$selectOptions['style'] = 'width:100%';
$selectOptions['class'] = ' select2 select2-hidden-accessible';


?>

<?php


$form = ActiveForm::begin(); ?>
    <div class="box-body">




        <?php  echo  $form->field($model, 'id',['labelOptions'=>['style'=>'display:none']])->hiddenInput(['value' => $model->id]); ?>
        <?php echo  $form->field($model, 'custom_name',['labelOptions'=>['style'=>'display:none']])->hiddenInput(['value' => $model->custom_name]);?>
        <?php echo  $form->field($model, 'spec_id',['labelOptions'=>['style'=>'display:none']])->hiddenInput(['value' => $model->spec_id]);?>
        <?php echo  $form->field($model, 'attr_field_name',['labelOptions'=>['style'=>'display:none']])->hiddenInput(['value' => $model->attr_field_name]);?>

        <?php if ($model->custom_type!=1): ?>

            <div class="col-md-6">
                <?php  echo  $form->field($model, 'attr_spec_id')->label( '特性名称')->dropDownList( $attrSpecsDownList, [
                'prompt'=>'--请选择特性--'
            ]); ?>
            </div>
        <?php endif; ?>




        <div class="col-md-6">
            <?php  echo  $form->field($model, 'attr_spec_width')->label( '尺寸')->textInput(['maxlength' => 64]); ?>
        </div>

        <div class="col-md-6">
            <?php  echo  $form->field($model, 'show_name')->label( '显示的别名')->textInput(['maxlength' => 64]); ?>
        </div>



        <div class="col-md-6">
            <?php  echo  $form->field($model, 'sort')->label( '显示的顺序')->textInput(['maxlength' => 64]); ?>
        </div>



    </div>

    <div class="form-group box-footer">
        <?php echo Html::submitButton($model->getIsNewRecord() ? Yii::t('region', 'Create') : Yii::t('region', 'Update'), [
            'class' => $model->getIsNewRecord() ? 'btn btn-success' : 'btn btn-primary', ]); ?>
        <?php echo Html::a(Yii::t('region', 'Cancel'), Yii::$app->request->getReferrer(), ['class' => 'btn btn-default']); ?>
    </div>

<?php ActiveForm::end(); ?>

<?php

$js = <<<JS
jQuery('#customtableview-attr_spec_id').on('change',function() {
    
    $.post('/config/custom/autoattr?attr_spec_id='+$(this).val(),          
      
    function(data){
    $("#customtableview-attr_spec_width").val(data.results.attr_spec_width);
    $("#customtableview-show_name").val(data.results.attr_spec_name);
 
                      
     });
});
JS;
$this->registerJs($js);

?>

